home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
dev
/
lang
/
PPCsmalltalk.lha
/
PPCSmallTalk
/
parser
/
y.tab.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-10-19
|
21KB
|
745 lines
#define LITNUM 257
#define LITFNUM 258
#define LITCHAR 259
#define LITSTR 260
#define LITSYM 261
#define CLASS 262
#define ASSIGN 263
#define BINARY 264
#define PRIMITIVE 265
#define PSEUDO 266
#define UPPERCASEVAR 267
#define LOWERCASEVAR 268
#define COLONVAR 269
#define KEYWORD 270
#define LP 271
#define RP 272
#define LB 273
#define RB 274
#define PERIOD 275
#define BAR 276
#define MBAR 277
#define SEMI 278
#define UPARROW 279
#define PS 280
#define MINUS 281
#define PE 282
#line 26 "parser.y"
#include "env.h"
#include "drive.h"
#include "parser.h"
#line 31 "parser.y"
typedef union {
struct litlist *a;
struct blockstruct *b;
char *c;
struct exprstruct *e;
int i;
struct keylist *k;
struct classstruct *l;
struct methodstruct *m;
struct objstruct *o;
/* enum pseuvars */ int p;
struct primlist *r;
struct statestruct *s;
struct litstruct *t;
struct primstruct *u;
} YYSTYPE;
#line 49 "parser.y"
extern struct blockstruct *mkblock();
extern struct classstruct *mkclass();
extern struct varstruct *mkvar(), *addvlist(), *invlist();
extern struct methodstruct *mkmethod();
extern struct exprstruct *mkexpr(), *mkkey();
extern struct keylist *mkklist();
extern struct statestruct *mkstate();
extern struct objstruct *mkobj();
extern struct primstruct *mkprim();
extern struct primlist *addprim();
extern struct litstruct *mklit();
extern struct litlist *addlit();
extern char *bincat();
struct varstruct *instvars;
struct varstruct *contextvars;
int bytetop = 0;
uchar bytearray[1000];
YYSTYPE e;
int errorcount = 0;
#define yyclearin yychar = -1
#define yyerrok yyerrflag = 0
extern int yychar;
extern short yyerrflag;
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 150
#endif
YYSTYPE yylval, yyval;
#define YYERRCODE 256
#line 348 "parser.y"
#include <stdio.h>
char *filename;
FILE *fp;
FILE *ofd;
FILE *fdout; /* added WMK */
#include "lex.yy.c"
main(argc, argv)
int argc;
char **argv;
{
long status;
if (argc < 2) quiter("parser: wrong number of arguments");
filename = argv[1];
fp = fopen(filename, "r");
if (fp == NULL) {
yerr("cannot open input file %s", filename);
quiter("parser quits");
}
/* added by WMK */
if (argc==3) {
ofd = fopen(argv[2],"w");
if (ofd==NULL) {
yerr("Cannot open output file %s", argv[2]);
quiter("parser quits");
}
}
else ofd = stdout;
status = (long)yyparse();
if (argc==3) fclose(ofd);
exit(status);
}
quiter(s) char *s; {
/* WMK changed this--was fprintf(stderr..) */
printf("%s\n", s); exit(10);
}
yywarn(s, v) char *s, *v; {
/* WMK again */
printf("%s: line %d: Warning ", filename, linenum);
printf(s, v);
printf("\n");
}
yyerror(s) char *s; {yerr(s, "");}
yerr(s, v)
char *s, *v;
{
/* WMK changed */
printf("%s: line %d: ", filename, linenum);
printf(s, v);
printf("\n");
if (errorcount++ > 10) quiter("too many errors, goodby");
}
expect(str) char *str;
{ char buffer[100];
sprintf(buffer,"Expected %%s found %s", yytext);
yerr(buffer, str);
}
int yywrap() { return(1);}
char *alloc(size) int size; /* allocate a block of storage */
{ char *p, *malloc();
p = malloc( (unsigned) size);
if (p == (char *) 0) yyerror("out of free space");
return(p);
}
char *bincat(s1, s2)
char *s1, *s2;
{ char *p;
p = alloc(strlen(s1) + strlen(s2) + 1);
strcpy(p, s1);
strcat(p, s2);
return(p);
}
short yyexca[] = {
-1, 1,
0, -1,
-2, 0,
};
#define YYNPROD 119
#define YYLAST 309
short yyact[]={
81, 79, 75, 76, 77, 127, 92, 25, 157, 141,
124, 123, 126, 125, 131, 156, 140, 155, 36, 26,
152, 37, 28, 130, 132, 29, 81, 79, 75, 76,
77, 127, 89, 25, 154, 149, 124, 123, 126, 125,
131, 120, 10, 119, 34, 26, 114, 40, 28, 130,
132, 29, 81, 79, 75, 76, 77, 15, 105, 9,
71, 65, 14, 116, 32, 33, 67, 146, 72, 107,
106, 35, 107, 43, 98, 78, 80, 147, 81, 79,
75, 76, 77, 15, 48, 42, 71, 65, 14, 54,
99, 84, 67, 91, 72, 143, 47, 109, 108, 102,
138, 78, 80, 81, 79, 75, 76, 77, 15, 13,
6, 71, 65, 14, 54, 15, 5, 67, 136, 72,
14, 69, 62, 101, 58, 52, 78, 80, 81, 79,
75, 76, 77, 15, 53, 60, 71, 65, 14, 54,
24, 51, 67, 93, 72, 81, 79, 75, 76, 77,
15, 78, 80, 71, 65, 14, 116, 31, 22, 67,
83, 72, 94, 17, 129, 45, 25, 142, 78, 80,
21, 20, 23, 25, 70, 41, 39, 25, 26, 95,
2, 28, 7, 27, 29, 26, 34, 90, 28, 26,
27, 29, 28, 34, 27, 29, 88, 46, 84, 44,
20, 49, 100, 96, 86, 87, 32, 33, 30, 4,
63, 8, 1, 32, 33, 12, 85, 66, 121, 64,
117, 139, 97, 122, 135, 134, 113, 50, 133, 16,
115, 112, 3, 118, 11, 19, 74, 103, 137, 144,
110, 82, 104, 111, 38, 61, 59, 57, 55, 56,
18, 73, 68, 145, 150, 0, 148, 0, 0, 0,
0, 0, 0, 0, 128, 0, 0, 122, 0, 0,
151, 0, 0, 153, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 128 };
short yypact[]={
-146,-146,-1000,-214,-147,-1000,-1000,-1000, -98,-1000,
-1000,-212,-198,-1000,-1000,-1000,-256,-1000,-212,-223,
-183,-1000,-1000,-183, -87,-1000,-1000,-1000,-1000,-1000,
-1000,-172,-1000,-1000,-1000,-1000,-1000, -98,-154,-177,
-183,-1000,-1000,-1000,-1000,-1000, -63,-1000,-1000,-1000,
-243,-1000,-129,-1000,-170,-272,-1000,-1000, -91, -91,
-194,-178,-1000,-1000,-1000,-1000,-1000,-129,-1000,-1000,
-1000,-158,-211,-1000,-1000,-1000,-1000,-1000,-201,-1000,
-160,-1000, -70,-1000,-1000,-1000,-1000,-1000,-1000,-154,
-1000,-129,-1000,-224,-112,-112,-224,-112,-1000,-1000,
-229,-231,-1000,-179,-260,-1000,-1000,-162,-1000,-1000,
-1000,-1000,-1000,-1000,-112,-194,-1000, -87,-194,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-204,-1000,-160,-205,-239,-179,-1000,-255,-129,-1000,
-1000,-1000,-240,-1000, -87,-257,-1000,-1000,-1000,-1000,
-1000,-267,-1000,-1000,-1000,-1000,-1000,-1000 };
short yypgo[]={
0, 123, 252, 210, 162, 140, 251, 250, 249, 248,
124, 135, 247, 246, 245, 244, 242, 241, 237, 236,
235, 143, 234, 232, 163, 229, 122, 228, 227, 141,
134, 225, 224, 118, 221, 219, 121, 218, 217, 212,
180, 211, 209, 208, 157, 197, 196, 175, 160, 174,
167, 164 };
short yyr1[]={
0, 39, 39, 40, 41, 41, 23, 42, 42, 22,
22, 22, 3, 3, 43, 43, 45, 45, 45, 25,
25, 24, 7, 7, 7, 7, 20, 20, 47, 47,
15, 15, 44, 44, 44, 17, 17, 48, 28, 28,
46, 46, 29, 29, 30, 30, 9, 9, 12, 12,
13, 13, 14, 14, 8, 8, 21, 21, 10, 10,
4, 4, 5, 5, 5, 5, 5, 11, 11, 26,
26, 26, 26, 26, 26, 26, 38, 27, 27, 2,
18, 18, 16, 16, 31, 31, 33, 33, 34, 34,
32, 32, 35, 35, 49, 36, 36, 36, 36, 36,
36, 6, 6, 19, 19, 37, 37, 37, 37, 37,
37, 37, 37, 51, 51, 1, 1, 50, 50 };
short yyr2[]={
0, 1, 2, 4, 1, 1, 3, 1, 1, 1,
2, 1, 1, 1, 0, 3, 1, 2, 1, 1,
3, 4, 1, 2, 1, 1, 2, 3, 1, 1,
0, 3, 1, 1, 1, 1, 2, 1, 1, 3,
0, 1, 2, 1, 3, 1, 1, 1, 1, 2,
1, 3, 2, 2, 1, 2, 2, 3, 1, 3,
1, 2, 1, 1, 1, 1, 1, 1, 2, 1,
1, 1, 1, 1, 3, 1, 4, 0, 2, 4,
0, 2, 1, 2, 2, 1, 2, 1, 0, 1,
2, 3, 1, 3, 2, 1, 1, 1, 1, 1,
4, 1, 2, 1, 2, 1, 1, 1, 1, 1,
1, 1, 3, 2, 1, 0, 2, 1, 2 };
short yychk[]={
-1000, -39, -40, -23, -42, 262, 256, -40, -41, 273,
256, -22, -3, 256, 267, 262, -25, -24, -7, -20,
-4, 268, 256, 270, -5, 264, 276, 281, 279, 282,
-43, -44, 276, 277, 256, 269, 274, 277, -15, -44,
270, -47, 268, 256, -47, -5, -45, 268, 256, -24,
-28, -29, 279, -30, 268, -9, -8, -12, -10, -13,
-11, -14, -26, -3, -35, 266, -38, 271, -2, -36,
-49, 265, 273, -6, -19, 259, 260, 261, 280, 258,
281, 257, -17, -48, 268, -47, -44, 268, -46, 275,
-30, 263, 278, -21, -4, 270, -21, -4, 268, 268,
-30, -1, 257, -18, -16, 269, 271, 273, 258, 257,
-44, -48, -29, -30, 270, -11, 268, -10, -11, 272,
272, -37, -36, 268, 267, 270, 269, 262, -4, -51,
280, 271, 281, -27, -31, -32, -33, -30, 279, -34,
276, 269, -50, 257, -10, -1, 271, 282, -26,